﻿using System.Collections.Generic;
using Duo1JHttpServer.Framework.Server;
using Duo1JHttpServer.Framework.Utils;

namespace Duo1JHttpServer.Handler
{
    class IndexHandler : AbstractHttpHandler
    {
        public override void GetHandler()
        {
            HtmlFormatter formatter = new HtmlFormatter().AddHtmlTagStart()
                .AddBodyTagStart()
                .AddLineHtml("h1", "Index");

            foreach (KeyValuePair<string, string> kv in requestModel.RequestParams)
            {
                formatter.AddLineHtml("p", $"{kv.Key}: {kv.Value}");
            }

            formatter.AddBodyTagEnd()
                .AddHtmlTagEnd();
            requestModel.OutputWriter.WriteLine(formatter.GetHtmlResult());
        }

        public override void PostHandler()
        {
        }
    }
}